package com.maxdu.labs.stt.utils;

import java.util.List;

import android.util.Log;

import com.maxdu.labs.stt.constants.Constants;
import com.maxdu.labs.stt.models.FriendRequest;
import com.maxdu.labs.stt.models.User;
import com.maxdu.labs.stt.models.db.FriendRequestDBHelper;

public class FriendRequestUtils {
	
	public static void sendRequest(String userId, List<User> friendsToInvite){
		if (friendsToInvite != null && friendsToInvite.size() > 0){
			for (User friend : friendsToInvite){
				FriendRequest friendRequest = new FriendRequest(userId, friend.getUserId());
				friendRequest.saveToCloud();
			}
		}else if (friendsToInvite != null){
			Log.w(Constants.LOG_TAG,"WARNING: trying to send request but the list of users to invite is NULL");
		}else{
			Log.w(Constants.LOG_TAG,"WARNING: trying to send request but the list of users to invite is EMPTY");
		}
	}
	
	public static List<FriendRequest> getFriendRequestsOfAUser(String userId){
		return FriendRequestDBHelper.getFriendRequestsOfAUser(userId);
	}
	
	public static void acceptFriendRequest(String userId, String receiverId){
		FriendRequestDBHelper friendRequestDBHelper = new FriendRequestDBHelper();

		friendRequestDBHelper.acceptFriendRequest(userId,receiverId);
	}
}
